#|/usr/bin/python

import yaml

def word_count(filename):
    wordlist = open(filename, 'r').read().split()
    wordfreq = [wordlist.count(p) for p in wordlist]
    dictionary = dict(zip(wordlist,wordfreq))
    aux = [(dictionary[key], key) for key in dictionary]
    aux.sort()
    aux.reverse()
    return aux

def wc_to_yaml(wc, filename):
    f = open(filename, 'w')
    yaml.dump(wc, f)
    f.close()	

import sys

if __name__ == '__main__':
   args = sys.argv[1:]
   for item in args:
       wc = word_count(item)
       wc_to_yaml(wc, 'wc_' + item)
